package com.tojabo.swing.four;

import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

public class RadioButtonDemo {
	static final int WIDTH=300;
    static final int HEIGHT=200;
	public static void main(String[] args) {

		JFrame jf = new JFrame("测试程序");
		jf.setSize(WIDTH, HEIGHT);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setVisible(true);
		JPanel contentPane = new JPanel();
		jf.setContentPane(contentPane);
		JRadioButton jr1 = new JRadioButton("忽略");// 创建三个单选按钮，并且将它们添加到内容面板中
		JRadioButton jr2 = new JRadioButton("继续");
		JRadioButton jr3 = new JRadioButton("跳过");
		ButtonGroup  bg=new ButtonGroup();//将三个单选按钮划分到一个按钮组中
        bg.add(jr1);
        bg.add(jr2);
        bg.add(jr3);
		contentPane.add(jr1);
		contentPane.add(jr2);
		contentPane.add(jr3);
	}

}
